home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Crack It!
/
Crack It!.iso
/
CONTENT
/
FHEXEDIT
/
HEXFUNCS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-09-09
|
854b
|
59 lines
{
***
HEXFUNCS.PAS
Unit Implementing Decimal-Hexadecimal and Hexadecimal-Decimal Conversions
(C)Copyright Gerard Paul Java 1996
***
}
unit HexFuncs;
interface
type
HexByte = string[2];
function ToHex(X: byte): HexByte;
function FromHex(Digit: char): byte;
implementation
function ToHex(X: byte): HexByte;
var
Digit1,
Digit2: byte;
function HexOneDigit(Y: byte): char;
var
Result: byte;
begin
if Y < $A then
Result := Y
else
Result := Y+7;
Inc(Result,48);
HexOneDigit := Chr(Result);
end;
begin
Digit1 := X mod 16;
Digit2 := X div 16;
ToHex := HexOneDigit(Digit2)+HexOneDigit(Digit1);
end;
function FromHex(Digit: char): byte;
begin
case Digit of
'0'..'9': FromHex := Ord(Digit)-48;
'A'..'F': FromHex := Ord(Digit)-55;
end;
end;
end.